<template>
	<view class="content">
		<view class="title">
			子组件B
		</view>
		<view class="b-box">
			ComA组件传进来的值:
			<text class="intent-text-box">
				{{result}}
			</text>
		</view>
		<view class="b-box" style="margin: 10rpx;">
			<text>回传值:</text>
			<input type="text" v-model="callBackValue" style="color: yellow;" />
			<button @click="sendOutside()" size="mini">回传</button>
		</view>
	</view>
</template>

<script>
export default {
  data() {
    return {
      result: '',
      callBackValue: ''
    }
  },
  created() {
    uni.$on('compAtoCompB', (val) => {
      this.result = val
    })
  },
  methods: {
    sendOutside() {
      this.$emit('callBackFun', this.callBackValue)
    }
  }
}
</script>
<style>
.content {
  background: lightgreen;
  padding: 20rpx;
  margin: 20rpx;
}
.title {
  font-size: 32rpx;
  font-weight: bold;
  margin-bottom: 10rpx;
}
.b-box {
  margin: 10rpx 0;
}
.intent-text-box {
  background: blue;
  color: white;
  padding: 2rpx 6rpx;
}
</style>
